package com.lihepeng.leecode.array2.qianzhuihe;

import org.junit.Test;

/**
 * 前缀和
 * 一位前缀和
 * sum[i] = sum[i-1]+a[i]
 * 前i 个数的和
 */
public class Solution01 {
    public int[] prexSumArray(int []arrs){
        int []nums = new int[arrs.length];
        for (int i=0;i<arrs.length;i++){
            if (i==0){
                nums[i] = arrs[i];
            }else {
                nums[i] = nums[i-1]+arrs[i];
            }
        }
        return nums;
    }
    @Test
    public void runTest(){
        int []arrs = {1,2,3,6,9,10};
        int[] ints = prexSumArray(arrs);
        for (int i :ints){
            System.out.println(i);
        }
    }

}
